package org.hgvc.webapp.ets.jsf.beans.admin;

import java.util.List;

import org.hgvc.webapp.ets.bo.Partner;
import org.hgvc.webapp.ets.bo.PartnerDocumentCheckList;
import org.hgvc.webapp.ets.constant.PartnerConstant;
import org.hgvc.webapp.ets.spring.service.PartnerService;
import org.jocsb.base.AbstractBean;
import org.jocsb.base.exception.BaseException;



public class AdminPartnerCheckListBean extends AbstractBean {

	private Partner partner;
	private PartnerService service;
	public static final String BEAN_NAME="adminPartnerCheckListBean";
	private List<PartnerDocumentCheckList> mandatoryList;
	private List<PartnerDocumentCheckList> notmandatoryList;
	public static final String NAV_DOC_CHECK_LIST="adminPartnerDocCheckList";
	public Partner getPartner() {
		return partner;
	}
	public void setPartner(Partner partner) {
		this.partner = partner;
	}
	public void setService(PartnerService service) {
		this.service = service;
	}

	/*---------------------------------------------------------------------------------*/
	
	public String navDocCheckListAction(Partner partner){
		this.partner = partner;
		return NAV_DOC_CHECK_LIST.concat("_"+getRoleName());
	}
	
	public List<PartnerDocumentCheckList> getMandatoryList() {
		try{
			mandatoryList = service.getPartnerDocumentCheckListWithType(PartnerConstant.PARTNER_DOC_MANDATORY, partner.getPartnerId());
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return mandatoryList;
	}
	public List<PartnerDocumentCheckList> getNotmandatoryList() {
		try{
			notmandatoryList = service.getPartnerDocumentCheckListWithType(PartnerConstant.PARTNER_DOC_NOT_MANDATORY, partner.getPartnerId());
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return notmandatoryList;
	}
	
	public String checkAction(){
		try{
			service.checkPartnerDocumentSubmission(mandatoryList, notmandatoryList, getThisUser());
			return AdminPartnerPendingApprovalManagementBean.NAV_LIST_PARTNER.concat("_"+getRoleName());
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return NAV_DOC_CHECK_LIST.concat("_"+getRoleName());
	}
	
	public String completeAction(){
		try{
			service.completePartnerDocumentSubmission(partner,mandatoryList, notmandatoryList, getThisUser());
			return AdminPartnerPendingApprovalManagementBean.NAV_LIST_PARTNER.concat("_"+getRoleName());
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return NAV_DOC_CHECK_LIST.concat("_"+getRoleName());
	}
}
